funcmain() { var wg sync.WaitGroup wg.Add(2) c := make(chanint) var send chan <- int = c var recv <- chan = c gofunc() { defer wg.Done() for x := range recv { println(x) } }() gofunc() { defer wg.Done() for i:=0;i<3;i++ { send <-I } }() wg.Wait() }
func(s *Skeleton) Run(closeSig chanbool) { for { select { case <-closeSig: s.commandServer.Close() s.server.Close() for !s.g.Idle() || !s.client.Idle() { s.g.Close() s.client.Close() } return case ri := <-s.client.ChanAsynRet: s.client.Cb(ri) case ci := <-s.server.ChanCall: s.server.Exec(ci) case ci := <-s.commandServer.ChanCall: s.commandServer.Exec(ci) case cb := <-s.g.ChanCb: s.g.Cb(cb) case t := <-s.dispatcher.ChanTimer: t.Cb() } } }